home *** CD-ROM | disk | FTP | other *** search
/ PC & Mediji 1998 February / PCM_9802.iso / programi / director / data.z / Behavior Library.cst / 00033_Script_UI Toggle Button < prev    next >
Text File  |  1997-05-09  |  4KB  |  116 lines

  1. -- Setting   Toggle Button
  2.  
  3.  
  4.  
  5. -- Behaves like a 'toggle', will be set in ON state and OFF state by clicking.
  6. -- also functions through lingo by handling message 'Toggle' and 'SetValue {0|1}', 
  7. -- for example if this behavior was assigned to sprite 5, use
  8. -- sendsprite 5, #Toggle
  9.  
  10.  
  11. property  NormalMember, NormalMemberNum, ToggleMember, ImageCastLib
  12. property  Setting
  13. property tracking
  14.  
  15. on mouseDown me
  16.   set the tracking of me = TRUE
  17.   toggle me
  18. end
  19.  
  20. on mouseEnter me
  21.   if the tracking of me then     
  22.     toggle me
  23.   end if
  24. end
  25.  
  26. on mouseLeave me
  27.   if the tracking of me then
  28.     toggle me
  29.   end if
  30. end
  31.  
  32. on mouseup me
  33.   if the tracking of me then
  34.     set the tracking of me = false
  35.   end if
  36. end
  37.  
  38. on mouseupOutside me
  39.   if the tracking of me then
  40.     set the tracking of me = false
  41.   end if
  42. end
  43.  
  44.  
  45. on Toggle me
  46.   setValue( me, NOT the Setting of me )
  47. end
  48.  
  49. on SetValue me, v_me
  50.   if v_me = 0 then  -- setting "OFF"
  51.     set the member of sprite the spriteNum of me = the normalMember of me
  52.     set the Setting of me = 0
  53.   else              -- setting "ON"
  54.     set the member of sprite the spriteNum of me = the toggleMember of me
  55.     set the Setting of me = 1
  56.   end if
  57.   updateStage
  58. end
  59.  
  60.  
  61. on beginSprite me
  62.   set s = the spriteNum of me
  63.   set the normalMemberNum of me = the memberNum of sprite s
  64.   set the imageCastLib of me = the number of castLib ¼
  65.                                  the castLibNum of sprite s
  66.   set the normalMember of me = member the normalMemberNum of me ¼
  67.      of castLib the imageCastLib of me
  68.   set the toggleMember of me = member the toggleMemberNum of me ¼
  69.       of castLib the imageCastLib of me  
  70.   SetValue( me, the Setting of me )
  71.   
  72. end
  73.  
  74. on getPropertyDescriptionList
  75.   if the currentspritenum = 0 then 
  76.     set memdefault = 0 
  77.   else
  78.     set memref = the member of sprite the currentspritenum
  79.     set castlibnum = the castlibnum of memref
  80.     set memdefault = member (the membernum of member memref + 1) of castlib castlibnum
  81.   end if
  82.   
  83.   set p_list = [ ¼
  84.      #toggleMemberNum: [ #comment: "Toggle Image:", ¼
  85.                           #format: #graphic, ¼
  86.                          #default:  memdefault ], ¼
  87.              #Setting: [ #comment: "Initially Toggled:", ¼
  88.                           #format: #boolean, ¼
  89.                          #default:  FALSE ] ¼
  90.                  ]
  91.   return p_list
  92. end
  93.  
  94. on SetToggleValue me, v_me
  95.   -- duplicate of SetValue, used by radioButton behavior
  96.   
  97.   if v_me = 0 then  -- setting "OFF"
  98.     set the member of sprite the spriteNum of me = the normalMember of me
  99.     set the Setting of me = 0
  100.   else              -- setting "ON"
  101.     set the member of sprite the spriteNum of me = the toggleMember of me
  102.     set the Setting of me = 1
  103.   end if
  104.   updateStage
  105. end
  106.  
  107. on getBehaviorDescription
  108.   return ¼
  109. "Makes a sprite work as a toggle button with automatic highlighting and mouse tracking. The behavior responds when clicked, or when the SetToggleValue or Toggle messages are receieved. Use the the UI Radio Group behavior to control toggle buttons in radio button groups." & RETURN & ¼
  110. "PARAMETERS:" & RETURN & ¼
  111. "ò Toggle Image - Choose the cast member to display when the button is toggled." & RETURN & ¼
  112. "ò Initially Toggled - Turn this option to make the button toggled when it first appears." & RETURN & ¼
  113. "MESSAGES:"& RETURN & ¼
  114. "ò SetToggleValue {TRUE or FALSE} - Sets the toggle button."& RETURN & ¼
  115. "ò Toggle - Switches the toggle button state."
  116. end